package cn.simonfish.carrier.kit;

import com.jfinal.ext.kit.DateKit;
import com.jfinal.kit.PropKit;

import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by simon on 2017/9/19.
 */
public class SerialNumberKit {

    private static final AtomicInteger SEED = new AtomicInteger();

    public static String generate(String prefix){
        String dateStr = DateKit.toStr(new Date(),"yyMMddHHmmss");
        int serial = SEED.incrementAndGet()%1000;
        return prefix+dateStr+ PropKit.get("node.code")+ NumberKit.fill(serial,3);
    }
}
